//
//  MarketDataManager.m
//  BTCoin
//
//  Created by Robin on 04/04/2018.
//  Copyright © 2018 Robin. All rights reserved.
//

#import "MarketDataManager.h"
#import "NSJSONSerialization+RemovingNulls.h"
#import "KLineDataModel.h"

@implementation MarketDataManager
DEFINE_SINGLETON_FOR_CLASS(MarketDataManager)

- (instancetype)init {
    self = [super init];
    if (self) {
        _chartArray = [[NSMutableArray alloc] init];
        _dayArray = [[NSMutableArray alloc] init];
    }
    
    return self;
}

- (void)parseKLineDataByType:(NSString*)type array:(NSArray*)array {
    if ([type isEqualToString:MIN1]) {
        [_chartArray removeAllObjects];
    } else if ([type isEqualToString:DAY]) {
        [_dayArray removeAllObjects];
    }
    
    for (int i = 0; i < array.count; i++) {
        KLineDataModel * m = [[KLineDataModel alloc] initWithDictionary:array[i] error:nil];
        
        if ([type isEqualToString:MIN1]) {
//            [_chartArray addObject:[m generateKLineData]];
        } else if ([type isEqualToString:DAY]) {
//            [_dayArray addObject:[m generateKLineData]];
        }
    }
}

@end
